package cn.home.service.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.home.common.annotation.Log;
import cn.home.common.core.controller.BaseController;
import cn.home.common.core.domain.AjaxResult;
import cn.home.common.enums.BusinessType;
import cn.home.service.domain.HomePerformanceDoctor;
import cn.home.service.service.IHomePerformanceDoctorService;
import cn.home.common.utils.poi.ExcelUtil;
import cn.home.common.core.page.TableDataInfo;

/**
 * 医生业绩目标Controller
 * 
 * @author xsc
 * @date 2025-04-09
 */
@RestController
@RequestMapping("/doctorper/doctorper")
public class HomePerformanceDoctorController extends BaseController
{
    @Autowired
    private IHomePerformanceDoctorService homePerformanceDoctorService;

    /**
     * 查询医生业绩目标列表
     */
    @PreAuthorize("@ss.hasPermi('doctorper:doctorper:list')")
    @GetMapping("/list")
    public TableDataInfo list(HomePerformanceDoctor homePerformanceDoctor)
    {
        startPage();
        List<HomePerformanceDoctor> list = homePerformanceDoctorService.selectHomePerformanceDoctorList(homePerformanceDoctor);
        return getDataTable(list);
    }

    /**
     * 导出医生业绩目标列表
     */
    @PreAuthorize("@ss.hasPermi('doctorper:doctorper:export')")
    @Log(title = "医生业绩目标", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HomePerformanceDoctor homePerformanceDoctor)
    {
        List<HomePerformanceDoctor> list = homePerformanceDoctorService.selectHomePerformanceDoctorList(homePerformanceDoctor);
        ExcelUtil<HomePerformanceDoctor> util = new ExcelUtil<HomePerformanceDoctor>(HomePerformanceDoctor.class);
        util.exportExcel(response, list, "医生业绩目标数据");
    }

    /**
     * 获取医生业绩目标详细信息
     */
    @PreAuthorize("@ss.hasPermi('doctorper:doctorper:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(homePerformanceDoctorService.selectHomePerformanceDoctorById(id));
    }

    /**
     * 新增医生业绩目标
     */
    @PreAuthorize("@ss.hasPermi('doctorper:doctorper:add')")
    @Log(title = "医生业绩目标", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HomePerformanceDoctor homePerformanceDoctor)
    {
        return toAjax(homePerformanceDoctorService.insertHomePerformanceDoctor(homePerformanceDoctor));
    }

    /**
     * 修改医生业绩目标
     */
    @PreAuthorize("@ss.hasPermi('doctorper:doctorper:edit')")
    @Log(title = "医生业绩目标", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HomePerformanceDoctor homePerformanceDoctor)
    {
        return toAjax(homePerformanceDoctorService.updateHomePerformanceDoctor(homePerformanceDoctor));
    }

    /**
     * 删除医生业绩目标
     */
    @PreAuthorize("@ss.hasPermi('doctorper:doctorper:remove')")
    @Log(title = "医生业绩目标", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(homePerformanceDoctorService.deleteHomePerformanceDoctorByIds(ids));
    }
}
